<template>
<div class="personnel-management views-container">
    <div class="wlm-table">
        <div class="wlm-table-hearder-btn">
            <router-link tag="span" to="/setting/personnelManagementAdd">
                <el-button size="small" type="primary">添加员工</el-button>
            </router-link>
        </div>
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.announcement.files" size="small" label-width="80px" class="retail-form" label-position="right">
                <el-form-item label="员工账号：" class="search">
                    <el-input @keyup.enter.native="filesSerch" v-model="tableFormatData.announcement.files.user_name" placeholder="请输入员工账号" style="width:200px;"></el-input>
                </el-form-item>
                <el-form-item label="" class="filter">
                    <el-form-item label="状态：">
                        <el-select v-model="tableFormatData.announcement.files.is_use" placeholder="请选择">
                            <el-option :label="'全部'" value="3">
                            </el-option>
                            <el-option :label="'启用'" value="1">
                            </el-option>
                            <el-option :label="'禁用'" value="0">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-table-content">
            <el-table :ref="tableFormatData.announcement.key" :data="tableFormatData.announcement.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <el-table-column type="selection" width="55">
                </el-table-column>
                <el-table-column prop="date" label="员工账号" >
                    <template slot-scope="scope">
                        <span>{{scope.row.user_name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="员工姓名" >
                    <template slot-scope="scope">
                        <span>{{scope.row.real_name||'-'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="所属角色" >
                    <template slot-scope="scope">
                        <span>{{scope.row.name||'-'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="状态" >
                    <template slot-scope="scope">
                        <el-switch :active-value="1" :inactive-value="0" :disabled="scope.row.is_super=='1'" @change="changeTableItem({store_user_id:scope.row.store_user_id,is_use:scope.row.is_use},tableFormatData.announcement.change.is_use)" v-model="scope.row.is_use"> </el-switch>
                    </template>
                </el-table-column>
                <el-table-column prop="address" label="操作" >
                    <template slot-scope="scope" v-if="scope.row.is_super!='1'">
                        <div class="operation-group">
                            <router-link class="wlm-text" tag="span" :to="{path:'/setting/personnelManagementAdd', query:{store_user_id:scope.row.store_user_id}}">
                                <el-button type="text">编辑</el-button>
                            </router-link>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.store_user_id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-content flex-row flex-justify-b flex-align-c">
                <el-row class="pagination-btns">
                    <el-checkbox class="check-all" true-label="1" false-label="0" v-model="tableFormatData.announcement.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row>
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.announcement.pagination.page" :page-sizes="tableFormatData.announcement.pagination.pagesizes" :page-size.sync="tableFormatData.announcement.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.announcement.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  getStoreUserList,
  delStoreUserInfo,
  updateStoreUserInfo
} from '@/api/setting'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'PersonnelManagement',
  components: {

  },
  data() {
    return {
      tableFormatData: {
        current: 'announcement',
        announcement: {
          key: 'announcement',
          api: {
            getList: getStoreUserList,
            delList: delStoreUserInfo
          },
          tableData: [],
          files: {
            user_name: '',
            is_use: '3',
            ids: [],
            checkall: '0',
            Recycle: '0',
            redirect: 'store_user_id'
          },
          change: {
            is_use: {
              name: '编辑',
              key: 'is_use',
              api: updateStoreUserInfo
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {

  }
}
</script>
